package 排序;

import java.util.Arrays;

/**
 *
 * <p>
 * 1、
 * <p/>
 * User: zhaixiaolong Date:2024/3/13 13:50 ProjectName: algorithm Version:
 */
public class 冒泡排序 {

    public static void main(String[] args) {
        int[] array = {5, 3, 9, 6, 2, 8, 4};
        sortMaoPao(array);
        System.out.println(Arrays.toString(array));
    }

    /**
     * 5\3\9\6\2\8\4
     *
     * @param array
     * @return
     */
    public static void sortMaoPao(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[j] < array[i]) {
                    int temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }
        }
    }
}
